<include file="Common:header" title="管理员列表·"/>
<div id="wrapper">
	<div class="wrapper wrapper-content">

		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title"><h5>管理员列表</h5></div>
					<div class="ibox-content">
						<div class="row">
							<div class="col-lg-12">
								<div class="col-xs-12 col-sm-2">
								<a href="{:U('Sys/admin_add')}">
									<button class="btn btn-danger">
										<i class="ace-icon glyphicon glyphicon-plus"></i>
										添加管理员
									</button>
								</a>
								</div>

								<div class="col-xs-12 col-sm-5">
									<form name="admin_list_sea" class="form-search" method="post" action="{:U('Sys/admin_list')}">
										<div class="input-group">
											<input type="text" name="val" id="val" class="form-control search-query admin_sea" value="{$testval}" placeholder="输入需查询的用户名" />
											<span class="input-group-btn">
											<button type="submit" class="btn btn-purple">
												<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
												搜索
											</button>
										</span>
										</div>
									</form>
								</div>
								<div class="input-group-btn">
									<a href="{:U('Sys/admin_list')}">
										<button type="button"  class="btn  btn-info">
											<span class="ace-icon fa fa-globe icon-on-right bigger-110"></span>
											显示全部
										</button>
									</a>
								</div>
							</div>
						</div>
						<div class="table-responsive"><br/>
							<table width="100%" class="table table-bordered table-hover">
								<thead>
								<tr>
									<th >登录用户名</th>
									<th >邮箱</th>
									<th >真实姓名</th>
									<th >电话号码</th>
									<th >创建时间</th>
									<th >状态</th>
									<th style="border-right:#CCC solid 1px;">操作</th>
								</tr>
								</thead>

								<tbody>
								<foreach name="data" item="v">
									<tr>
										<td height="28" >{$v.username}</td>
										<td>{$v.email}</td>
										<td>{$v.nickname}</td>
										<td>{$v.mobile}</td>
										<td>{$v['create_time']|date="Y-m-d",###}</td>
										<td>
											<if condition="$v[status] eq 1">
												<button style="margin:0;" type="button" class="btn btn-xs btn-primary" onclick="change({$v.id},this);">状态开启</button>
												<else/>
												<button style="margin:0;" type="button" class="btn btn-xs btn-danger" onclick="change({$v.id},this);">状态禁止</button>
											</if>
										</td>
										<td>
													<a style="margin:0;" class="btn btn-xs btn-info" href="{:U('Sys/admin_edit',array('id'=>$v['id']))}"><i class="fa fa-pencil" style="font-size: 14px;"></i>&nbsp;编辑</a>
													<a style="margin:0;" class="btn btn-xs btn-danger" onclick="del({$v.admin_id});"><i class="fa fa-trash" style="font-size: 14px;"></i>&nbsp;删除</a></a>
										</td>
									</tr>
								</foreach>
								<tr>
									<td height="50" colspan="10" align="right">{$page}</td>
								</tr>
								</tbody>

							</table>

						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<include file="Common:footer"/>
<script>
	//    状态按钮
	function change(id,btn) {
		$.post("{:U('Sys/admin_state')}",{id:id},function (data) {
			$(btn).text(data.info);
			if(data.info=='状态开启'){
				$(btn).removeClass('btn-danger');
				$(btn).addClass('btn-primary');
			}else{
				$(btn).removeClass('btn-primary');
				$(btn).addClass('btn-danger');
			}
		});
	}
	//删除
	function del(id) {
		layer.confirm('你确定要删除吗？', {icon: 3}, function(index){
			$.post("{:U('Sys/admin_list_del')}",{id:id},function (data) {
				console.log(data);
				layer.msg(data.info,{time:1500},function () {window.location.href=data.url});

			});
			layer.close(index);
		});
	}

</script>
